/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.sdkj.dspservice.modules.demand.dao;

import com.sdkj.dspservice.common.base.dao.CrudDao;
import com.sdkj.dspservice.modules.demand.entity.Demand;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 需求类型DAO接口
 * @author tm
 */
public interface DemandStatisticsDao extends CrudDao<Demand> {
    /**
     * 按类型统计数量
     * @param demand
     * @return
     */
    @Select("select coalesce(t.name,'总计') as name,count(*) as value from demand_demand a left join demand_type t on t.id = a.type_id where a.delete_flag = '0' and a.status != '0' group by rollup (t.name)")
    List<Map<String, Object>> statisticsByType(Demand demand);
}
